<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>mandel</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="mags.html" title="mags" />
    <link rel="next" href="mandol.html" title="mandol" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">mandel</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="mags.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="mandol.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="mandel"></a>
      <div class="titlepage"></div>
      <a id="IndexMandel" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">mandel</span>
        </h2>
        <p>mandel — 
     Mandelbrot set
          </p>
      </div>
      <div class="refsect1">
        <a id="idp122462464"></a>
        <h2>Description</h2>
        <p>
	Returns the number of iterations corresponding to a given point of complex plane by applying the Mandelbrot set formula.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp122463792"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">kiter, koutrig <span class="command"><strong>mandel</strong></span>  ktrig, kx, ky, kmaxIter</pre>
      </div>
      <div class="refsect1">
        <a id="idp122531360"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kiter</em></span> - number of iterations
    </p>
        <p>
      <span class="emphasis"><em>koutrig</em></span> - output trigger signal
    </p>
        <p>
      <span class="emphasis"><em>ktrig</em></span> - input trigger signal
    </p>
        <p>
      <span class="emphasis"><em>kx, ky</em></span> - coordinates of a given point belonging to the complex plane
    </p>
        <p>
      <span class="emphasis"><em>kmaxIter</em></span> - maximum iterations allowed
    </p>
        <p>
     <span class="emphasis"><em>mandel</em></span> is an opcode that allows the use of the Mandelbrot set formula to generate an output that can be applied to any musical (or non-musical) parameter. It has two output arguments: <span class="emphasis"><em>kiter</em></span>, that contains the iteration number of a given point, and <span class="emphasis"><em>koutrig</em></span>, that generates a trigger 'bang' each time <span class="emphasis"><em>kiter</em></span> changes. A new number of iterations is evaluated only when <span class="emphasis"><em>ktrig</em></span> is set to a non-zero value. The coordinates of the complex plane are set in <span class="emphasis"><em>kx</em></span> and <span class="emphasis"><em>ky</em></span>, while <span class="emphasis"><em>kmaxIter</em></span> contains the maximum number of iterations. Output values, which are integer numbers, can be mapped in any sorts of ways by the composer.
     </p>
      </div>
      <div class="refsect1">
        <a id="idp122540704"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the mandel opcode. It uses the file <a class="ulink" href="examples/mandel.csd" target="_top"><em class="citetitle">mandel.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp122542560"></a>
          <p class="title">
            <strong>Example 469. Example of the mandel opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o mandel.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
<span class="comment">;example by Brian Evans</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="oblock">instr</span> 1

ipitchtable <span class="op">=</span> 1						<span class="comment">; pitch table in score      </span>
ipitchndx <span class="op">=</span> p5						<span class="comment">; p5=pitch index from table</span>
    
ipitch <span class="opc">table</span>  ipitchndx, ipitchtable   
kenv   <span class="opc">expseg</span> 1.0, 1.0, 1.0, 11.5, .0001              
asig   <span class="opc">pluck</span>  <span class="opc">ampdb</span>(p4)<span class="op">*</span>kenv, <span class="opc">cpspch</span>(ipitch), <span class="opc">cpspch</span>(ipitch), 0, 1
       <span class="opc">outs</span>   asig, asig
       
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">f</span>1 0 32 -2 6.00 6.02 6.04 6.05 6.07 6.09 6.11		<span class="comment">; f1 is a pitch table defining a four octave C major scale starting </span>
           7.00 7.02 7.04 7.05 7.07 7.09 7.11		<span class="comment">; on C two octaves below middle C</span>
           8.00 8.02 8.04 8.05 8.07 8.09 8.11
           9.00 9.02 9.04 9.05 9.07 9.09 9.11

<span class="comment">;ins start   dur ampdb(p4) pitchndx(p5)</span>

<span class="stamnt">i</span>1   0       12.0   75     3 
<span class="stamnt">i</span>1   1.5999  12.0   75     4 
<span class="stamnt">i</span>1   3.4000  12.0   75     5 
<span class="stamnt">i</span>1   4.2000  12.0   75     6 
<span class="stamnt">i</span>1   4.4000  12.0   75     7 
<span class="stamnt">i</span>1   4.6000  12.0   75     9 
<span class="stamnt">i</span>1   4.8000  12.0   75     10 
<span class="stamnt">i</span>1   5.0000  12.0   75     5 
<span class="stamnt">i</span>1   5.2000  12.0   75     27 
<span class="stamnt">i</span>1   5.4000  12.0   75     5 
<span class="stamnt">i</span>1   5.6000  12.0   75     20 
<span class="stamnt">i</span>1   6.0000  12.0   75     24 
<span class="stamnt">i</span>1   6.2000  12.0   75     2 
<span class="stamnt">i</span>1   6.4000  12.0   75     27 
<span class="stamnt">i</span>1   6.6000  12.0   75     20 
<span class="stamnt">i</span>1   6.8000  12.0   75     15 
<span class="stamnt">i</span>1   7.0000  12.0   75     3 
<span class="stamnt">i</span>1   7.2000  12.0   75     3 
<span class="stamnt">i</span>1   7.4000  12.0   75     23 
<span class="stamnt">i</span>1   7.6000  12.0   75     9 
<span class="stamnt">i</span>1   7.8000  12.0   75     17 
<span class="stamnt">i</span>1   8.0000  12.0   75     18 
<span class="stamnt">i</span>1   8.2000  12.0   75     3 
<span class="stamnt">i</span>1   8.4000  12.0   75     26 
<span class="stamnt">i</span>1   8.6000  12.0   75     15 
<span class="stamnt">i</span>1   8.8     12.0   75     2 
<span class="stamnt">i</span>1   9       12.0   75     26 
<span class="stamnt">i</span>1   9.2     12.0   75     8 
<span class="stamnt">i</span>1   9.3999  12.0   75     22 
<span class="stamnt">i</span>1   9.5999  12.0   75     22 
<span class="stamnt">i</span>1   9.7999  12.0   75     20 
<span class="stamnt">i</span>1   9.9999  12.0   75     19 
<span class="stamnt">i</span>1   10.399  12.0   75     20 
<span class="stamnt">i</span>1   10.799  12.0   75     22 
<span class="stamnt">i</span>1   10.999  12.0   75     27 
<span class="stamnt">i</span>1   11.199  12.0   75     25 
<span class="stamnt">i</span>1   11.399  12.0   75     20 
<span class="stamnt">i</span>1   11.599  12.0   75     21 
<span class="stamnt">i</span>1   11.799  12.0   75     24 
<span class="stamnt">i</span>1   11.999  12.0   75     24 
<span class="stamnt">i</span>1   12.199  12.0   75     4 
<span class="stamnt">i</span>1   12.399  12.0   75     13 
<span class="stamnt">i</span>1   12.599  12.0   75     15 
<span class="stamnt">i</span>1   12.799  12.0   75     14 
<span class="stamnt">i</span>1   12.999  12.0   75     3 
<span class="stamnt">i</span>1   13.199  12.0   75     21 
<span class="stamnt">i</span>1   13.399  12.0   75     6 
<span class="stamnt">i</span>1   13.599  12.0   75     3 
<span class="stamnt">i</span>1   13.799  12.0   75     10 
<span class="stamnt">i</span>1   13.999  12.0   75     25 
<span class="stamnt">i</span>1   14.199  12.0   75     21 
<span class="stamnt">i</span>1   14.399  12.0   75     20 
<span class="stamnt">i</span>1   14.599  12.0   75     19 
<span class="stamnt">i</span>1   14.799  12.0   75     18 
<span class="stamnt">i</span>1   15.199  12.0   75     17 
<span class="stamnt">i</span>1   15.599  12.0   75     16 
<span class="stamnt">i</span>1   15.999  12.0   75     15 
<span class="stamnt">i</span>1   16.599  12.0   75     14 
<span class="stamnt">i</span>1   17.199  12.0   75     13 
<span class="stamnt">i</span>1   18.399  12.0   75     12 
<span class="stamnt">i</span>1   18.599  12.0   75     11 
<span class="stamnt">i</span>1   19.199  12.0   75     10 
<span class="stamnt">i</span>1   19.799  12.0   75     9 
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
     </p>
      </div>
      <div class="refsect1">
        <a id="idp122546848"></a>
        <h2>See Also</h2>
        <p>
      More information on this opcode: <a class="ulink" href="http://mymbs.mbs.net/~pfisher/FOV2-0010016C/FOV2-0010016E/FOV2-001001A3/chapters/35evans/intro.html" target="_top"><em class="citetitle">Composing Fractal Music with Csound</em></a>, by Brian Evans
    </p>
      </div>
      <div class="refsect1">
        <a id="idp122548976"></a>
        <h2>Credits</h2>
        <p>Written by Gabriel Maldonado.</p>
        <p>New in Csound 5 (Previously available only on CsoundAV)</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="mags.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="mandol.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">mags </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> mandol</td>
        </tr>
      </table>
    </div>
  </body>
</html>
